function [combos_all,combos_all_unique] = combinations_2(m_regr,J)

%% NB: this allows for one value for m(1) and a different value for m(2)-m(J) (i.e. the latter J-1 must be the same!)

m = m_regr+1;

temp = cell(length(m_regr),1);
for i=1:length(m_regr)
    
    temp{i} = 1:m_regr(length(m_regr)-i+1)+1;
    
end
combos_all = allcomb(temp{:});     
combos_all = combos_all(:,[length(m_regr):-1:1]);       % key is that the index that moves "faster" is in the first column, then second one, and so on
                                            % (has to be consistent with order of theta)
                                          
%% combos_all_unique

combos_all_unique = combos_all;

% others_unique = multicombos([1:m(2)]',J-1);        % use this for x_{-j}
% 
% temp_cell = cell(J-1,1);
% for j=1:J-1
%     
%     temp_cell{j} = (1:m(2));
%     
% end
% others_all = allcomb(temp_cell{:});             % use this for z_{-j}
% 
% temp = [];
% for i=1:m(2)                                       % add first column
%     
%     temp = [temp;
%             i*ones(size(others_unique,1),1) others_unique];
%         
% end
% 
% combos_all_unique = uint8(temp);
% clear temp


end